<template>
  <a-card style="width: 100%">
    <a-form :form="form" layout="vertical">
      <a-row :gutter="48">
        <a-col :span="24">
          <a-form-item
            label="父母信息补充时间更新"
          >
            <a-range-picker v-decorator="[
              'lrsj',
              {
                rules: [{ required: true, message: '请选择录入时间!' }],
              }
            ]"/>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-button style="margin-left: 125px;" type="primary" @click="handleSave">保存</a-button>
        </a-col>
      </a-row>
    </a-form>
  </a-card>
</template>
<script>
// import moment from 'moment'
import { mapState } from 'vuex'
import ACol from "ant-design-vue/es/grid/Col";

export default {
  name: 'StuEditTime',
  components: {ACol},
  data () {
    return {
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo
    })
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  created () {
    this.$api.student.parentGetTime().then(res => {
      this.$nextTick(() => {
          console.log(res)
          this.form.setFieldsValue({lrsj: [res.data.startDate, res.data.endDate]})
      })
    })
  },
  methods: {
    // 保存操作
    handleSave () {
      this.form.validateFields((err, values) => {
        if (err) {
          return
        }
        let params = {startDate: values.lrsj[0].format('YYYY-MM-DD') + ' 00:00:00', endDate: values.lrsj[1].format('YYYY-MM-DD') + ' 23:59:59'}
        this.$api.student.parentUpdateTime(params).then(res => {
          this.$message.success(res.msg)
        })
      })
    }
  }
}
</script>
